<template>
  <el-button @click="copy">点击复制</el-button>
  <div style="padding: 1rem">
    {{ copyContent }}
  </div>
</template>

<script>
import {ref,unref, getCurrentInstance, watch, reactive, onMounted} from "vue";
import {ElMessage, ElMessageBox} from 'element-plus';
import {useRouter} from "vue-router";
import useClipboard from "vue-clipboard3";

export default {
  name: "index",
  components:{

  },
  setup(props ,content){
    const router = useRouter()
    const {proxy} = getCurrentInstance();


    const {toClipboard} = useClipboard()
    let data = {
      copyContent: ref("复制内容"),
    }
    //监听
    watch(() => [props.info], ([newInfo],[oldInfo]) => {

    })
    onMounted(async () => {

    })
    let methods = {

      async copy() {
        try {
          await toClipboard(data.copyContent.value)
          ElMessage.success("复制成功");
        } catch (e) {
          ElMessage.error("复制失败" + e);
        }

      },
    }

    return {
      proxy,
      router,
      toClipboard,
      ...data,
      ...methods
    }
  }
}
</script>

<style lang="scss" scoped>

</style>